package com.example.endusation.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    private final String uploadBaseDir = "D:/uploaded_files/"; // 与后端保存文件的根目录一致

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 将 URL 中 /uploaded/** 映射到本地的 uploadBaseDir 目录
        registry.addResourceHandler("/uploaded/**")
                .addResourceLocations("file:" + uploadBaseDir);
    }
}
